﻿# cmake_minimum_required(VERSION 2.8.0)
cmake_minimum_required(VERSION 3.6)
set(PROJECT_NAME HILibDill)

set(MODULE_HILIBDILLAPI HILibDill)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g  -m64")

# Use c and asm
if(MSVC)
    enable_language(C CXX ASM_MASM)
else()
    enable_language(C CXX ASM)
endif()

# 设置编译器标志
#set(CMAKE_ASM_NASM_COMPILER nasm)  # 使用NASM作为汇编器
#set(CMAKE_ASM_NASM_FLAGS "-f win64")  # 指定NASM编译选项

#set(CMAKE_C_STANDARD 99)
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fno-stack-protector")
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-stack-protector")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O2 -fPIC")
# CPPFLAGS += -fPIC
#add_definitions(-D__GNUC__)
add_definitions(-DOS_LINUX)
add_definitions(-D__linux__)
add_definitions(-DDILL_DISABLE_SOCKETS)
add_definitions(-DDILL_POLL)
add_definitions(-DDILL_SOCKETS)
add_definitions(-DDILL_THREADS)



# add_compile_options(-fno-stack-protector)
# add_definitions(-D_SEMAPHORE_H)
SET(LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/lib") # 设置lib库输出路径
include_directories(
	include
)

# head file path，头文件目录
# INCLUDE_DIRECTORIES(
# include
# )
# set(LD_LIBRARY_PATH $LD_LIBRARY_PATH:${PROJECT_SOURCE_DIR}/libs)
# file(GLOB SRC_LIST "*.c" "*.cpp")
file(GLOB SRC_LIST "src/*.c" "src/*.cpp" "src/*.S")

set(LIBS pthread) # 添加我生成的两个库文件名
add_library(${MODULE_HILIBDILLAPI} ${SRC_LIST}) # 编译utils.cpp utils.h生成静态库文件utility，同时工程名也变成utility
target_link_libraries(${MODULE_HILIBDILLAPI} ${LIBS}) # 生成可执行文件main，需要把连接库给带上，添加库文件名不需要指定文件路径，cmake会自己找

#target_compile_options(${MODULE_HILIBDILLAPI} PRIVATE "${libmill_la_CFLAGS}")
